package com.yuyou.fn.platform.service.impl;

import com.github.wens.mybatisplus.examples.Example;
import org.springframework.stereotype.Service;

import com.yuyou.fn.platform.mapper.OauthMapper;
import com.yuyou.fn.platform.entity.Oauth;
import com.yuyou.fn.platform.service.IOauthService;
import com.github.wens.framework.service.impl.SuperServiceImpl;

/**
 *
 * Oauth 表数据服务层接口实现类
 *
 */
@Service
public class OauthServiceImpl extends SuperServiceImpl<OauthMapper, Oauth,Long> implements IOauthService {


    @Override
    public Oauth findByOpenId(String openId) {
        Example<Oauth> example = Oauth.createExample();
        example.createCriteria().andEqualTo("openId" , openId );
        return findOneByExample(example);
    }

    @Override
    public void saveOauth(Long userId, String openId, Integer platform) {
        Oauth oauth = new Oauth();
        oauth.setOpenId(openId);
        oauth.setWhichPlatform(platform);
        oauth.setUserId(userId);
        insertSelective(oauth);
    }
}